package com.egoo.ticket.server.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.egoo.ticket.server.pojo.dto.PageOutputDto;
import com.egoo.ticket.server.service.WorkBanchDataService;
import com.egoo.ticket.server.utils.common.ConstantCode;
import com.egoo.ticket.server.utils.common.DbResponse;
import com.egoo.ticket.server.utils.common.ResponseConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;

import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author Donny_dong
 */
@Slf4j
@RestController
@RequestMapping(value = "/v1/workBanchData", produces = "application/json")
@Api(value = "工作台小结数据", tags = "工作台小结数据", description = "工作台小结数据")
public class WorkBanchDataController {

	@Autowired
	private WorkBanchDataService workBanchDataService;

	@ApiOperation(value = "查询数据", notes = "查询数据")
	@RequestMapping(method = RequestMethod.POST, value = "/selectAll")
	public DbResponse selectAll(@RequestBody JSONObject jsonObject) {
		JSONArray columns = jsonObject.getJSONArray("columns");
		if (columns == null){
			return new DbResponse(ResponseConstant.RES_FAIL_CODE,"参数格式不对,请用正确格式:"+"{"+"columns"+":"+"[]"+"}");
		}
		List<Map<String,Object>> list = JSON.parseObject(columns.toJSONString(), List.class);
//		ArrayList<Map<String,Object>> arrayList = new ArrayList<>();
//		arrayList.add(map);
		DbResponse dbResponse = workBanchDataService.selectByCondition(list);
		return dbResponse;
	}


}
